home *** CD-ROM | disk | FTP | other *** search
/ NBC Slam Jams! / NBC Slam Jams!.iso / xtras / media_la / fx_set_2.fxm / 00081_Script_Slider Bar < prev    next >
Text File  |  1998-07-02  |  4KB  |  143 lines

  1. property pThumbSprite, pFillSprite, pArrowsSprite, pTextSprite, pTextField, pCurVal, pExtraChar, pActive, pCallBackObj, pRefcon
  2. property pRange, pMin, pMax, pSliderLeft, pSliderWidth, pStartOrEnd
  3.  
  4. on new me, propList
  5.   set pFillSprite = getAProp(propList,#fillSprite)
  6.   set pThumbSprite = getAProp(propList,#thumbSprite)
  7.   set pArrowsSprite = getAProp(propList,#arrowsSprite)
  8.   set pTextSprite = getAProp(propList,#textSprite)
  9.   set pTextField = getAProp(propList,#textField)
  10.   set pMin = getAProp(propList,#min)
  11.   set pMax = getAProp(propList,#max)
  12.   set pCurVal = getAProp(propList, #cur)
  13.   set pSliderLeft = getAProp(propList,#left)
  14.   set pSliderWidth = getAProp(propList,#width)
  15.   set pExtraChar = getAProp(propList,#suffix)
  16.   set pActive = getAProp(propList,#active)
  17.   set pCallBackObj = getAProp(propList,#callback)
  18.   set pRefCon = getAProp(propList,#ref)
  19.   set pStartOrEnd = getAProp(propList,#startOrEnd)
  20.   
  21.   set pRange = pMax - pMin
  22.   setVal(me,pCurVal)
  23.   setEnabled(me,pActive)
  24.   
  25.   return(me)
  26. end
  27.  
  28. on wait me, waitTime
  29.   put the ticks into t
  30.   repeat while the ticks < t+waitTime
  31.   end repeat
  32. end
  33.  
  34. on Arrows me
  35.   if not pActive then exit
  36.   put the locH of the clickLoc into h1
  37.   put the locH of sprite the clickOn into h2
  38.   if h1 < h2 then
  39.     put "left" into side
  40.     put -1 into d
  41.   else
  42.     put "right" into side
  43.     put 1 into d
  44.   end if
  45.   set the member of sprite pArrowsSprite = member ("horizArrows"&&side)
  46.   set newVal = max(min(pCurVal+d,pMax),pMin)
  47.   setVal(me,newVal)
  48.   if objectP(pCallBackObj) then DoDrag(pCallBackObj, pRefcon, newVal)
  49.   updateStage
  50.   wait(me,5)
  51.   repeat while the stillDown
  52.     if rollover(pArrowsSprite) then
  53.       set the member of sprite pArrowsSprite = member ("horizArrows"&&side)
  54.       set pCurVal = max(min(pCurVal+d,pMax),pMin)
  55.     else
  56.       set the member of sprite pArrowsSprite = member "horizArrows"
  57.     end if
  58.     setVal(me,pCurVal)
  59.     if objectP(pCallBackObj) then DoDrag(pCallBackObj, pRefcon, newVal)
  60.     wait(me,5)
  61.   end repeat
  62.   set the member of sprite pArrowsSprite = member "horizArrows"
  63.   if objectP(pCallBackObj) then EndChange(pCallBackObj)
  64. end
  65.  
  66.  
  67. on Drag me
  68.   if not pActive then exit
  69.   repeat while the stillDown
  70.     put min(max(the mouseH,pSliderLeft),pSliderLeft+pSliderWidth) into h
  71.     set the locH of sprite pThumbSprite = h
  72.     setFill(me)
  73.     updateStage
  74.     set loc = the locH of sprite pThumbSprite - pSliderLeft   
  75.     set pCurVal = ((pRange*loc)/(pSliderWidth))+pMin   
  76.     TextOut(me)
  77.     if objectP(pCallBackObj) then DoDrag(pCallBackObj, pRefcon, pCurVal)
  78.   end repeat
  79.   if objectP(pCallBackObj) then EndChange(pCallBackObj)
  80. end
  81.  
  82. on setFill me
  83.   if voidP(pFillSprite) then exit
  84.   puppetSprite pFillSprite, TRUE
  85.   
  86.   put the rect of sprite pFillSprite into fillRect
  87.   set the right of fillRect = the locH of sprite pThumbSprite
  88.   set the left of fillRect = pSliderLeft+1
  89.   set the rect of sprite pFillSprite = fillRect
  90. end
  91.  
  92. on CalcVal me, numerator, denom, otherDenom
  93.   set val = (otherDenom * numerator) / denom
  94.   return(val)
  95. end
  96.  
  97. on TextOut me
  98.   if voidP(pTextField) then exit
  99.   if voidP(pCurVal) then put " " into text
  100.   else put string(integer(pCurVal))&pExtraChar into text
  101.   if pActive = FALSE then set text = "-"
  102.   
  103.   if voidP(pStartOrEnd) then
  104.     put text into field pTextField
  105.   else if pStartOrEnd = #start then
  106.     set w = word 3 of field pTextField
  107.     if w = "" then set w = "-"
  108.     put text&&"to"&&w into field pTextField
  109.   else if pStartOrEnd = #end then
  110.     set w = word 1 of field pTextField
  111.     if w = "" then set w = "-"
  112.     put w&&"to"&&text into field pTextField
  113.   end if
  114. end
  115.  
  116.  
  117. on SetVal me, newVal
  118.   puppetSprite pThumbSprite, TRUE
  119.   set pCurVal = newVal
  120.   if voidP(newVal) then put pRange/2 into newVal
  121.   TextOut(me)
  122.   set loc = CalcVal(me, newVal-pMin, pRange, pSliderWidth)
  123.   set the locH of sprite pThumbSprite = pSliderLeft + loc
  124.   setFill(me)
  125.   --updateStage
  126. end
  127.  
  128. on SetEnabled me, enabled
  129.   set pActive = enabled
  130.   if not voidP(pFillSprite) then enableInterfaceElement(pFillSprite,enabled)
  131.   enableInterfaceElement(pThumbSprite,enabled)
  132.   enableInterfaceElement(pArrowsSprite,enabled)
  133.   if voidP(pStartOrEnd) then enableInterfaceElement(pTextSprite,enabled)
  134. end
  135.  
  136. on Release me
  137.   -- release all puppets, constraints, etc.
  138.   puppetSprite pFillSprite, FALSE
  139.   puppetSprite pThumbSprite, FALSE
  140. end
  141.  
  142.  
  143.